<%--
  Created by IntelliJ IDEA.
  User: 12088
  Date: 2023/7/25
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加模块</title>
    <script src="js/jquery.js"></script>
    <link rel="stylesheet" href="js/layui/css/layui.css">
</head>
<body style="padding: 20px">





<form class="layui-form " action="">

    <div class="layui-form-item" >
        <label class="layui-form-label">模块编号</label>
        <div class="layui-input-block">
            <input id="modId" type="text" class="layui-input" lay-verify="required" style="width: 200px;"> </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">模块名称</label>
        <div class="layui-input-block">
            <input id="modName" type="text" class="layui-input" lay-verify="required" style="width: 200px;"> </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">项目编号</label>
        <div class="layui-input-block" style="width: 200px;">
            <select name="project" lay-verify="required" lay-search="" id="prjId" >
                <option value="">请选择项目</option>
            </select>
        </div>
    </div>




        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-bg-blue" lay-submit lay-filter="save_filter">确认</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
</form>
</body>

<script src="js/layui/layui.js" charset="utf-8"></script>
<script>

    layui.use('form', function () {
        var form = layui.form;
        form.render();
        $.ajax({
            url:"getAllProjectList",
            type:"GET",
            dataType:"json",
            success:function(result){
                var list = result;    //返回的数据
                var project = document.getElementById("prjId"); //server为select定义的id
                for(var p in list){
                    var option = document.createElement("option");  // 创建添加option属性
                    option.setAttribute("value",list[p].id); // 给option的value添加值
                    option.innerText=list[p].id+"  ("+list[p].proName+")";     // 打印option对应的纯文本
                    project.appendChild(option);           //给select添加option子标签
                    form.render("select");            // 刷性select，显示出数据
                } }
        })




        form.on('submit(save_filter)', function(data){
            var index=parent.layer.getFrameIndex(window.name);
            window.parent.addMod($("#modId").val(),$("#modName").val(),$("#prjId").val());
            parent.layer.close(index);
            return false;
        });

    })










</script>
</html>
